{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "thrown-bathroom",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/search-in-a-binary-search-tree\n",
    "\n",
    "\n",
    "Runtime: 40 ms, faster than 82.69% of C++ online submissions for Search in a Binary Search Tree.\n",
    "Memory Usage: 34.7 MB, less than 78.33% of C++ online submissions for Search in a Binary Search Tree.\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include <vector>\n",
    "#include <algorithm>\n",
    "#include <map>\n",
    "#include <string>\n",
    "\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    TreeNode* searchBST(TreeNode* root, int val) {\n",
    "        //7:08\n",
    "        TreeNode* node = root;\n",
    "        while (node != nullptr) {\n",
    "            if (node->val == val) {\n",
    "                return node;\n",
    "            } else if (val < node->val) {\n",
    "                node = node->left;\n",
    "            } else if (val > node->val) {\n",
    "                node = node->right;\n",
    "            }\n",
    "        }\n",
    "        return nullptr;\n",
    "        //7:10\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "processed-conclusion",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
